package com.gdx.javatd;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;


public abstract class Entity implements Drawable {

	protected float X;
	protected float Y;
	
	protected static Texture baseTexture;
	protected Sprite baseSprite;

	public Entity(int X, int Y) {
		this.X = X;
		this.Y = Y;
		
		baseSprite = new Sprite(baseTexture);
	}
	
	public float getX() {
		return X;
	}

	public void setX(float x) {
		X = x;
	}

	public float getY() {
		return Y;
	}

	public void setY(float y) {
		Y = y;
	}
	
	public double distance(float x, float y) {
		return Math.sqrt((X-x)*(X-x) + (Y-y)*(Y-y));
	}
	
	public double angle(float x, float y) {
		return Math.toDegrees(Math.atan2(Y-y, X-x));
	}
	
	public static void setBaseTexture(Texture baseTexture) {
		Entity.baseTexture = baseTexture;
	}
	
	public void render(SpriteBatch batch) {
		batch.begin();
		baseSprite.setPosition(X, Y);
		baseSprite.draw(batch);
		batch.end();
	}
	
}
